package enumandlambda;

/**
 * @author shkstart
 * 线程优先级
 * @create 2022-11-29-12:41
 */
public class ThreadDemoByPriority {
    public static void main(String[] args) {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                //得到当前线程，并打印线程的优先级
                Thread t= Thread.currentThread();

                System.out.println("线程优先级:"+t.getPriority());

            }
        });
        System.out.println("线程优先级2:"+thread.getPriority());
        thread.start();
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("线程优先级3:"+thread.getPriority());
    }
}
